# 相机模型相关的算法

## 相机内/外参数计算 - 直接使用opencv自己带的
add_executable(alg_CameraIntrinsic1 alg_CameraIntrinsic1.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS} ${ME_EIGENMATH}
    )
target_compile_definitions(alg_CameraIntrinsic1 PUBLIC ME_NO_VTK)
target_link_libraries(alg_CameraIntrinsic1 ${OpenCV_LIBS})
qt5_use_modules(alg_CameraIntrinsic1 ${MEQT_LIB})


## 相机内部参数计算 - 按照张正友写的方法 （TODO: 结果个不对）
add_executable(alg_CameraIntrinsic2 alg_CameraIntrinsic2.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS} ${ME_EIGENMATH}
    )
target_compile_definitions(alg_CameraIntrinsic2 PUBLIC ME_NO_VTK)
target_link_libraries(alg_CameraIntrinsic2 ${OpenCV_LIBS})
qt5_use_modules(alg_CameraIntrinsic2 ${MEQT_LIB})

# 投影矩阵P来回计算
ADD_EXECUTABLE(alg_ProjectionMatrixToFrom alg_ProjectionMatrixToFrom.cpp
    CeresSolProjMatrix.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS}
    ${ME_VTKMATH})
TARGET_LINK_LIBRARIES(alg_ProjectionMatrixToFrom ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})

# 计算相机参数，通过ceres解方程
ADD_EXECUTABLE(alg_CameraParams1 alg_CameraParams1.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS} ${ME_EIGENMATH}
    )
target_compile_definitions(alg_CameraParams1 PUBLIC ME_NO_VTK)
TARGET_LINK_LIBRARIES(alg_CameraParams1 ${CERES_LIBRARIES} ${OpenCV_LIBS})
qt5_use_modules(alg_CameraParams1 ${MEQT_LIB})

# 计算相机参数，通过ceres解方程
ADD_EXECUTABLE(alg_CameraParams2 alg_CameraParams2.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS} ${ME_EIGENMATH}
    )
target_compile_definitions(alg_CameraParams2 PUBLIC ME_NO_VTK)
TARGET_LINK_LIBRARIES(alg_CameraParams2 ${CERES_LIBRARIES} ${OpenCV_LIBS})
qt5_use_modules(alg_CameraParams2 ${MEQT_LIB})

# 计算Dicom图的小钢球，并且知道小钢球的实际位置，计算相机参数
ADD_EXECUTABLE(alg_DicomCameraParams alg_DicomCameraParams.cpp
    CeresSolProjMatrix.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS}
    ${ME_VTKMATH}
    ${ALGORITHM_DICOMDETECT_SRCS}
    )
TARGET_LINK_LIBRARIES(alg_DicomCameraParams ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
vtk_module_autoinit(TARGETS alg_DicomCameraParams MODULES ${VTK_LIBRARIES})

# 根据已知数据，验证自己写的投影矩阵是否正确
ADD_EXECUTABLE(alg_ProjectionMatrixVerify alg_ProjectionMatrixVerify.cpp
    CeresSolProjMatrix.cpp
    ${ME_MEMATH_SRCS} ${ME_MEMATH_HDRS}
    ${ME_VTKMATH}
    ${ALGORITHM_DICOMDETECT_SRCS}
    )
TARGET_LINK_LIBRARIES(alg_ProjectionMatrixVerify ${VTK_LIBRARIES} ${ITK_LIBRARIES} ${OpenCV_LIBS} ${CERES_LIBRARIES})
vtk_module_autoinit(TARGETS alg_ProjectionMatrixVerify MODULES ${VTK_LIBRARIES})
